﻿Imports System
Imports System.Collections
Imports System.Collections.Generic

Namespace System.Workflow.Runtime
    <Serializable> _
    Friend NotInheritable Class EventQueueState
        ' Methods
        Friend Sub New()
        End Sub

        Friend Sub CopyFrom(ByVal copyFromState As EventQueueState)
            Me.deliveredMessages = New Queue(copyFromState.Messages)
            Me.asynchronousListeners.AddRange(copyFromState.AsynchronousListeners.ToArray)
            Me.synchronousListeners.AddRange(copyFromState.SynchronousListeners.ToArray)
            Me.enabled = copyFromState.Enabled
            Me.transactional = copyFromState.Transactional
            Me.dirty = False
        End Sub


        ' Properties
        Friend ReadOnly Property AsynchronousListeners As List([Of] ActivityExecutorDelegateInfo([Of] QueueEventArgs))
            Get
                Return Me.asynchronousListeners
            End Get
        End Property

        Friend Property Dirty As Boolean
            Get
                Return Me.dirty
            End Get
            Set(ByVal value As Boolean)
                Me.dirty = value
            End Set
        End Property

        Friend Property Enabled As Boolean
            Get
                Return Me.enabled
            End Get
            Set(ByVal value As Boolean)
                Me.enabled = value
            End Set
        End Property

        Friend ReadOnly Property Messages As Queue
            Get
                Return Me.deliveredMessages
            End Get
        End Property

        Friend ReadOnly Property SynchronousListeners As List([Of] ActivityExecutorDelegateInfo([Of] QueueEventArgs))
            Get
                Return Me.synchronousListeners
            End Get
        End Property

        Friend Property Transactional As Boolean
            Get
                Return Me.transactional
            End Get
            Set(ByVal value As Boolean)
                Me.transactional = value
            End Set
        End Property


        ' Fields
        Private asynchronousListeners As List([Of] ActivityExecutorDelegateInfo([Of] QueueEventArgs)) = New List([Of] ActivityExecutorDelegateInfo([Of] QueueEventArgs))
        Private deliveredMessages As Queue = New Queue
        <NonSerialized> _
        Private dirty As Boolean
        Private enabled As Boolean = True
        <NonSerialized> _
        Friend queueName As IComparable
        Private synchronousListeners As List([Of] ActivityExecutorDelegateInfo([Of] QueueEventArgs)) = New List([Of] ActivityExecutorDelegateInfo([Of] QueueEventArgs))
        Private transactional As Boolean = True
    End Class
End Namespace

